package com.kosta.board.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import com.kosta.board.domain.Board;
import com.kosta.board.service.BoardService;

public class BoardServiceImpl implements BoardService {

	private static Map<Integer, Board> boardRepo = new HashMap<Integer, Board>();

	public void saveBoard(Board board) {
		board.setId(boardRepo.values().size());
		boardRepo.put(board.getId(), board);
	}

	public List<Board> findBoards() {
		Iterator<Board> iter = boardRepo.values().iterator();
		List<Board> boards = new ArrayList<Board>();
		while (iter.hasNext()) {
			boards.add(iter.next());
		}
		return boards;
	}

	public Board findBoard(int id) {
		Board board = boardRepo.get(id);
		return board;
	}

}
